﻿namespace Vdc.Window
{
    using System;
    using System.Collections.Specialized;
    using System.ComponentModel;
    using System.Drawing.Design;
    using System.Text;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.Design;

    [ToolboxData("<{0}:Window runat=\"server\">[Window]</{0}:Window>"), Designer(typeof(WindowDesigner)), DefaultProperty("Window")]
    public class Window : Control, INamingContainer, IPostBackDataHandler
    {
        private bool blankID;
        private string hzIndex = "";
        private ScriptManagerHelper myScriptManager;
        private string myVersion = "1.0.0.1";

        public Window()
        {
            this.ViewState["InitialMode"] = InitialModes.NORMAL;
            this.ViewState["left"] = 0;
            this.ViewState["top"] = 0;
            this.ViewState["width"] = 320;
            this.ViewState["height"] = 240;
            this.ViewState["minwidth"] = 0;
            this.ViewState["minheight"] = 0;
            this.ViewState["opacity"] = 100;
            this.ViewState["visibleonload"] = true;
            this.ViewState["isdraggable"] = true;
            this.ViewState["isresizable"] = true;
            this.ViewState["ismodal"] = false;
            this.ViewState["closebutton"] = true;
            this.ViewState["minimizebutton"] = false;
            this.ViewState["maximizebutton"] = false;
            this.ViewState["showstatusbar"] = true;
            this.ViewState["title"] = "";
            this.ViewState["iconpath"] = "";
            this.ViewState["status"] = "";
            this.ViewState["pageopacity"] = 0x19;
            this.ViewState["OnClientInit"] = "";
            this.ViewState["OnClientPreOpen"] = "";
            this.ViewState["OnClientOpen"] = "";
            this.ViewState["OnClientPreClose"] = "";
            this.ViewState["OnClientClose"] = "";
            this.ViewState["OnClientResize"] = "";
            this.ViewState["OnClientDrag"] = "";
            this.ViewState["relativeelementid"] = "";
            this.ViewState["stylefolder"] = "";
            this.ViewState["url"] = null;
            this.ViewState["overflow"] = OverflowStyles.HIDDEN;
            this.ViewState["EnableClientSideControl"] = false;
            this.ViewState["DebugMode"] = true;
        }

        private bool CheckAjaxPageInheritance()
        {
            Type baseType = this.Page.GetType().BaseType;
            while (baseType != null)
            {
                if (baseType.ToString() == "OboutInc.oboutAJAXPage")
                {
                    return true;
                }
                try
                {
                    baseType = Activator.CreateInstance(baseType).GetType().BaseType;
                    continue;
                }
                catch
                {
                    return false;
                }
            }
            return false;
        }

        internal static Type GetBaseInterfaceType(Type t)
        {
            if (t.BaseType.ToString().IndexOf("Vdc.Window") == -1)
            {
                return t;
            }
            return GetBaseInterfaceType(t.BaseType);
        }

        private string getFormClientID()
        {
            Control parent = this.Parent;
            Control control2 = null;
            while (parent.GetType() != this.Page.GetType())
            {
                if (parent.GetType().ToString().IndexOf("HtmlForm") != -1)
                {
                    control2 = parent;
                    break;
                }
            }
            if (control2 != null)
            {
                return control2.ClientID;
            }
            return "noform";
        }

        private string initScript(string wID, bool includeScriptTags)
        {
            StringBuilder builder = new StringBuilder();
            if (includeScriptTags)
            {
                builder.Append("<script type='text/javascript' >");
            }
            builder.AppendFormat("var {0};", wID);
            builder.AppendFormat("function init{0}()", wID);
            builder.Append("{");
            builder.Append("try");
            builder.Append("{");
            builder.AppendFormat("{0} = new IWindow(", wID);
            builder.AppendFormat("'{0}'", wID);
            builder.Append(",");
            builder.AppendFormat("'{0}'", this.StyleRootFolder);
            builder.Append(",");
            builder.AppendFormat("'{0}'", (this.Style != "") ? this.Style : "default");
            builder.Append(",");
            builder.AppendFormat("'{0}'", this.RelativeElementID);
            builder.Append(",");
            builder.AppendFormat("'{0}'", wID + "_container");
            builder.Append(",");
            builder.AppendFormat("'{0}'", wID + "_content");
            builder.Append(",");
            builder.AppendFormat("'{0}'", this.InitialMode.ToString().ToLower());
            builder.Append(",");
            builder.AppendFormat("'{0}'", this.Title);
            builder.Append(",");
            builder.AppendFormat("'{0}'", this.IconPath);
            builder.Append(",");
            if (this.Url != null)
            {
                builder.AppendFormat("'{0}'", this.Url);
            }
            else
            {
                builder.Append("null");
            }
            builder.Append(",");
            builder.AppendFormat("'{0}'", this.Overflow);
            builder.Append(",");
            builder.AppendFormat("'{0}'", this.Status);
            builder.Append(",");
            builder.AppendFormat("{0}", this.Left);
            builder.Append(",");
            builder.AppendFormat("{0}", this.Top);
            builder.Append(",");
            builder.AppendFormat("{0}", this.Width);
            builder.Append(",");
            builder.AppendFormat("{0}", this.Height);
            builder.Append(",");
            builder.AppendFormat("{0}", this.MinWidth);
            builder.Append(",");
            builder.AppendFormat("{0}", this.MinHeight);
            builder.Append(",");
            builder.AppendFormat("{0}", this.Opacity);
            builder.Append(",");
            builder.AppendFormat("{0}", this.PageOpacity);
            builder.Append(",");
            builder.AppendFormat("{0}", this.VisibleOnLoad.ToString().ToLower());
            builder.Append(",");
            builder.AppendFormat("{0}", this.IsDraggable.ToString().ToLower());
            builder.Append(",");
            builder.AppendFormat("{0}", this.IsResizable.ToString().ToLower());
            builder.Append(",");
            builder.AppendFormat("{0}", this.IsModal.ToString().ToLower());
            builder.Append(",");
            builder.AppendFormat("{0}", this.ShowCloseButton.ToString().ToLower());
            builder.Append(",");
            builder.AppendFormat("{0}", this.ShowMinimizeButton.ToString().ToLower());
            builder.Append(",");
            builder.AppendFormat("{0}", this.ShowMaximizeButton.ToString().ToLower());
            builder.Append(",");
            builder.AppendFormat("{0}", this.ShowStatusBar.ToString().ToLower());
            builder.Append(",");
            builder.AppendFormat("{0}", "function(){" + this.OnClientInit + "}");
            builder.Append(",");
            builder.AppendFormat("{0}", "function(){" + this.OnClientPreOpen + "}");
            builder.Append(",");
            builder.AppendFormat("{0}", "function(){" + this.OnClientOpen + "}");
            builder.Append(",");
            builder.AppendFormat("{0}", "function(){" + this.OnClientDrag + "}");
            builder.Append(",");
            builder.AppendFormat("{0}", "function(){" + this.OnClientResize + "}");
            builder.Append(",");
            builder.AppendFormat("{0}", "function(){" + this.OnClientPreClose + "}");
            builder.Append(",");
            builder.AppendFormat("{0}", "function(){" + this.OnClientClose + "}");
            builder.Append(");");
            builder.Append("}");
            builder.Append("catch(e)");
            builder.Append("{");
            if (this.DebugMode)
            {
                builder.Append("alert('vdc Window init:'+e.toString());");
            }
            builder.Append("}");
            builder.Append("}");
            if (this.myScriptManager.isAjax || this.CheckAjaxPageInheritance())
            {
                builder.AppendFormat("init{0}();", wID);
            }
            else
            {
                builder.AppendFormat("old{0}load = window.onload;", wID);
                builder.Append("window.onload=function(evt)");
                builder.Append("{");
                builder.AppendFormat("if (old{0}load!=null) old{0}load();", wID);
                builder.AppendFormat("init{0}();", wID);
                builder.Append("};");
            }
            if (includeScriptTags)
            {
                builder.Append("</script> ");
            }
            return builder.ToString();
        }

        public bool LoadPostData(string postDataKey, NameValueCollection postCollection)
        {
            if (this.ID == null)
            {
                return false;
            }
            string str = postCollection["h_" + this.ID + "_mode"];
            if (str != null)
            {
                if (!(str == "nornal"))
                {
                    if (str == "maximize")
                    {
                        this.InitialMode = InitialModes.MAXIMIZE;
                        goto Label_005E;
                    }
                }
                else
                {
                    this.InitialMode = InitialModes.NORMAL;
                    goto Label_005E;
                }
            }
            this.InitialMode = InitialModes.NORMAL;
        Label_005E:
            this.Top = Convert.ToInt32(postCollection["h_" + this.ID + "_top"]);
            this.Left = Convert.ToInt32(postCollection["h_" + this.ID + "_left"]);
            this.Width = Convert.ToInt32(postCollection["h_" + this.ID + "_width"]);
            this.Height = Convert.ToInt32(postCollection["h_" + this.ID + "_height"]);
            this.Opacity = Convert.ToInt32(postCollection["h_" + this.ID + "_opacity"]);
            this.Title = postCollection["h_" + this.ID + "_title"];
            this.Status = postCollection["h_" + this.ID + "_status"];
            this.Url = (postCollection["h_" + this.ID + "_url"] != "__null") ? postCollection["h_" + this.ID + "_url"] : null;
            this.VisibleOnLoad = postCollection["h_" + this.ID + "_visible"] == "1";
            this.hzIndex = postCollection["h_" + this.ID + "_zIndex"];
            return true;
        }

        protected override void OnPreRender(EventArgs e)
        {
            if (this.ID == null)
            {
                this.blankID = true;
            }
            if (!this.blankID)
            {
                this.myScriptManager = new ScriptManagerHelper(this);
                this.myScriptManager.RegisterHiddenField(this, "h_" + this.ID + "_mode", this.InitialMode.ToString().ToLower());
                this.myScriptManager.RegisterHiddenField(this, "h_" + this.ID + "_top", this.Top.ToString());
                this.myScriptManager.RegisterHiddenField(this, "h_" + this.ID + "_left", this.Left.ToString());
                this.myScriptManager.RegisterHiddenField(this, "h_" + this.ID + "_width", this.Width.ToString());
                this.myScriptManager.RegisterHiddenField(this, "h_" + this.ID + "_height", this.Height.ToString());
                this.myScriptManager.RegisterHiddenField(this, "h_" + this.ID + "_opacity", this.Opacity.ToString());
                this.myScriptManager.RegisterHiddenField(this, "h_" + this.ID + "_title", this.Title);
                this.myScriptManager.RegisterHiddenField(this, "h_" + this.ID + "_status", this.Status);
                this.myScriptManager.RegisterHiddenField(this, "h_" + this.ID + "_url", (this.Url != null) ? this.Url : "__null");
                this.myScriptManager.RegisterHiddenField(this, "h_" + this.ID + "_visible", this.VisibleOnLoad ? "1" : "0");
                this.myScriptManager.RegisterHiddenField(this, "h_" + this.ID + "_zIndex", this.hzIndex);
                this.Page.RegisterRequiresPostBack(this);
                this.myScriptManager.RegisterOnSubmitStatement(this, "oWindowManager.sHD()", "oWindowManager.sHD()");
            }
        }

        public void RaisePostDataChangedEvent()
        {
        }

        protected override void Render(HtmlTextWriter writer)
        {
            string str;
            string str8;
            string iD = this.ID;
            bool flag = true;
            if (this.myScriptManager == null)
            {
                this.myScriptManager = new ScriptManagerHelper(this);
            }
            try
            {
                this.Page.VerifyRenderingInServerForm(this);
            }
            catch
            {
                flag = false;
            }
            writer.Write("\n\n<!--   vdc Window v." + this.myVersion + "  http://www.vdc.com.vn   -->\n\n");
            if (!this.myScriptManager.IsInAsyncCallback)
            {
                string key = "";
                if (this.StyleFolder != "")
                {
                    writer.Write(writeCSS(this.StyleFolder + "/" + this.Style + ".css"));
                    str = "";
                    key = this.StyleFolder + "/" + this.Style + ".js";
                    str = str + "<script type='text/javascript' src='" + key + "'></script>";
                    writer.Write(str);
                }
                else
                {
                    writer.Write(writeCSS(HttpUtility.HtmlEncode(this.Page.ClientScript.GetWebResourceUrl(GetBaseInterfaceType(base.GetType()), "Vdc.Window.default.css"))));
                    str = "";
                    key = HttpUtility.HtmlEncode(this.Page.ClientScript.GetWebResourceUrl(GetBaseInterfaceType(base.GetType()), "Vdc.Window.default.js"));
                    str = str + "<script type=\"text/javascript\" src=\"" + key + "\"></script>";
                    writer.Write(str);
                }

                str = "<script type='text/javascript'>if (typeof " + this.Style + "PreloadImage !=\"undefined\") " + this.Style + "PreloadImage('" + this.StyleFolder + "');</script>";
                if (!flag || this.CheckAjaxPageInheritance())
                {
                    writer.Write(str);
                }
                else
                {
                    this.myScriptManager.RegisterStartupScript(this, key, "if (typeof " + this.Style + "PreloadImage !=\"undefined\") " + this.Style + "PreloadImage('" + this.StyleFolder + "');", true);
                }
                str = "";
                string str4 = HttpUtility.HtmlEncode(this.Page.ClientScript.GetWebResourceUrl(GetBaseInterfaceType(base.GetType()), "Vdc.Window.resources.scripts.windowcore.min.js"));
                str = str + "<script type=\"text/javascript\" src=\"" + str4 + "\"></script>";
                writer.Write(str);
            }
            if (this.EnableClientSideControl)
            {
                writer.Write("<script>");
                writer.Write("__windowAlertsSRF='{0}';", this.StyleRootFolder);
                writer.Write("__windowAlertsDS='{0}';", this.Style);
                writer.Write("__windowAlertsWRS='{0}';", HttpUtility.HtmlEncode(this.Page.ClientScript.GetWebResourceUrl(GetBaseInterfaceType(base.GetType()), "Vdc.Window.none.gif")));
                writer.Write("function windowalert(message,title,type)");
                writer.Write("{");
                writer.Write("try { winalert(message,title,type); }");
                writer.Write("catch(e)");
                writer.Write("{");
                writer.Write("var iMes = (message==null)?\"null\":\"'\"+message+\"'\";");
                writer.Write("var iTit = (title==null)?\"null\":\"'\"+title+\"'\";");
                writer.Write("var iTyp = (type==null)?\"null\":\"'\"+type+\"'\";");
                writer.Write("setTimeout(\"windowalert(\"+iMes+\",\"+iTit+\",\"+iTyp+\")\",200);");
                writer.Write("}");
                writer.Write("}");
                writer.Write("</script>");
                str = "";
                string str5 = HttpUtility.HtmlEncode(this.Page.ClientScript.GetWebResourceUrl(GetBaseInterfaceType(base.GetType()), "Vdc.Window.resources.scripts.dialog.min.js"));
                str = str + "<script type=\"text/javascript\" src=\"" + str5 + "\"></script>";
                writer.Write(str);
                str = "";
                string str6 = HttpUtility.HtmlEncode(this.Page.ClientScript.GetWebResourceUrl(GetBaseInterfaceType(base.GetType()), "Vdc.Window.resources.scripts.builtinwindow.min.js"));
                str = str + "<script type=\"text/javascript\" src=\"" + str6 + "\"></script>";
                writer.Write(str);
            }
            if (this.blankID)
            {
                return;
            }
            if (!this.myScriptManager.IsInAsyncCallback)
            {
                str = "";
                string str7 = HttpUtility.HtmlEncode(this.Page.ClientScript.GetWebResourceUrl(GetBaseInterfaceType(base.GetType()), "Vdc.Window.resources.scripts.iwindow.min.js"));
                str = str + "<script type=\"text/javascript\" src=\"" + str7 + "\"></script>";
                writer.Write(str);
            }
            ExpireManager manager = new ExpireManager();
            if (manager.checkExpired() != 1)
            {
                this.Url = "";
            }
            writer.Write("<div id='{0}'>", iD + "_container");
            if (this.Url != null)
            {
                str8 = "";
                switch (this.Overflow)
                {
                    case OverflowStyles.AUTO:
                        str8 = "auto";
                        break;

                    case OverflowStyles.HIDDEN:
                        str8 = "no";
                        break;

                    case OverflowStyles.SCROLL:
                        str8 = "yes";
                        break;
                }
            }
            else
            {
                writer.Write("<div id='{0}' style='display:none;'>", iD + "_content");
                writer.Write("<iframe id='{0}' src='javascript:false;' style='display:none;'></iframe>", iD + "_back");
                switch (manager.checkExpired())
                {
                    case 0:
                        writer.Write("<center><div style=\"width:100%;text-align:center;border: 2px solid #cccccc;  font: 8pt verdana; background-color: #eeeeee;\"><a href=\"http://www.vdc.com.vn\">vdc Window</a><br />Evaluation has expired<br /><a href=\"http://www.vdc.com.vn/\">License ...</a></div></center>");
                        writer.Write("<div style='display:none'>");
                        base.Render(writer);
                        writer.Write("</div>");
                        break;

                    case 1:
                        base.Render(writer);
                        break;

                    case 2:
                        writer.Write("<center><div style=\"position:absolute;left:0px;top:-43px;text-align:center;border: 2px solid #cccccc; width:150px; height: 10 px;font: 8pt verdana; background-color: #eeeeee;\"><a href=\"http://www.vdc.com\">vdc Window</a><br />Evaluation has expired<br /><a href=\"http://www.vdc.com.vn/\">License ...</a></div></center>");
                        base.Render(writer);
                        break;
                }
                writer.Write("</div>");
                goto Label_049F;
            }
            writer.Write("<iframe id='{0}' src='javascript:false;' style='display:none;' scrolling='{1}' frameborder='0' ></iframe>", iD + "_ct", str8);
        Label_049F:
            writer.Write("</div>");
            if (!flag || this.CheckAjaxPageInheritance())
            {
                writer.Write(this.initScript(this.ID, true));
            }
            else
            {
                this.myScriptManager.RegisterStartupScript(this, this.ID, this.initScript(this.ID, false), true);
            }
        }

        internal static string writeCSS(string href)
        {
            string str = "";
            return (((((((str + "<script type=\"text/javascript\" language=\"javascript\">\n") + "(function(){\n" + "var head = document.getElementsByTagName('HEAD')[0];\n") + "if(head==null) head = document.body;\n" + "var linkElement = document.createElement('link');\n") + "linkElement.type = 'text/css';\n" + "linkElement.rel = 'StyleSheet';\n") + "linkElement.href = '" + href + "';\n") + "head.appendChild(linkElement);\n") + "})();\n" + "</script>\n");
        }

        [Description("Gets or sets whether error message will show when error occurs.")]
        public virtual bool DebugMode
        {
            get
            {
                return (bool) this.ViewState["DebugMode"];
            }
            set
            {
                this.ViewState["DebugMode"] = value;
            }
        }

        [Category("Extras"), Description("Gets or sets whether extra client-side functions can be used such as windowalert().")]
        public virtual bool EnableClientSideControl
        {
            get
            {
                return (bool) this.ViewState["EnableClientSideControl"];
            }
            set
            {
                this.ViewState["EnableClientSideControl"] = value;
            }
        }

        [Description("Gets or sets height of Window"), Category("Position and Size")]
        public virtual int Height
        {
            get
            {
                return (int) this.ViewState["height"];
            }
            set
            {
                this.ViewState["height"] = (value > this.MinHeight) ? value : this.MinHeight;
            }
        }

        [Category("Header Settings"), Description("Gets or sets IconPath of Window."), Editor(typeof(UrlEditor), typeof(UITypeEditor))]
        public virtual string IconPath
        {
            get
            {
                return (string) this.ViewState["iconpath"];
            }
            set
            {
                this.ViewState["iconpath"] = value;
            }
        }

        [Description("Gets or sets whether the initial mode of Window: normal or maximize."), Category("Header Settings")]
        public InitialModes InitialMode
        {
            get
            {
                return (InitialModes) this.ViewState["InitialMode"];
            }
            set
            {
                this.ViewState["InitialMode"] = value;
            }
        }

        [Category("Behaviours"), Description("Gets or sets whether Dialod can be dragged.")]
        public virtual bool IsDraggable
        {
            get
            {
                return (bool) this.ViewState["isdraggable"];
            }
            set
            {
                this.ViewState["isdraggable"] = value;
            }
        }

        [Category("Behaviours"), Description("Gets or sets whether Dialod is modal.")]
        public virtual bool IsModal
        {
            get
            {
                return (bool) this.ViewState["ismodal"];
            }
            set
            {
                this.ViewState["ismodal"] = value;
            }
        }

        [Description("Gets or sets whether Dialod can be resized."), Category("Behaviours")]
        public virtual bool IsResizable
        {
            get
            {
                return (bool) this.ViewState["isresizable"];
            }
            set
            {
                this.ViewState["isresizable"] = value;
            }
        }

        [Description("Gets or sets Left position of Window"), Category("Position and Size")]
        public virtual int Left
        {
            get
            {
                return (int) this.ViewState["left"];
            }
            set
            {
                this.ViewState["left"] = value;
            }
        }

        [Category("Position and Size"), Description("Gets or sets min height of Window")]
        public virtual int MinHeight
        {
            get
            {
                return (int) this.ViewState["minheight"];
            }
            set
            {
                this.ViewState["minheight"] = value;
                if (value > this.Height)
                {
                    this.Height = value;
                }
            }
        }

        [Category("Position and Size"), Description("Gets or sets min width of Window")]
        public virtual int MinWidth
        {
            get
            {
                return (int) this.ViewState["minwidth"];
            }
            set
            {
                this.ViewState["minwidth"] = value;
                if (value > this.Width)
                {
                    this.Width = value;
                }
            }
        }

        [Description("Gets or sets script for Window Close event."), Category("Events")]
        public virtual string OnClientClose
        {
            get
            {
                return (string) this.ViewState["OnClientClose"];
            }
            set
            {
                this.ViewState["OnClientClose"] = value;
            }
        }

        [Category("Events"), Description("Gets or sets script for Window Drag event.")]
        public virtual string OnClientDrag
        {
            get
            {
                return (string) this.ViewState["OnClientDrag"];
            }
            set
            {
                this.ViewState["OnClientDrag"] = value;
            }
        }

        [Category("Events"), Description("Gets or sets script for Window Init event.")]
        public virtual string OnClientInit
        {
            get
            {
                return (string) this.ViewState["OnClientInit"];
            }
            set
            {
                this.ViewState["OnClientInit"] = value;
            }
        }

        [Category("Events"), Description("Gets or sets script for Window Open event.")]
        public virtual string OnClientOpen
        {
            get
            {
                return (string) this.ViewState["OnClientOpen"];
            }
            set
            {
                this.ViewState["OnClientOpen"] = value;
            }
        }

        [Category("Events"), Description("Gets or sets script for Window Pre-Close event.")]
        public virtual string OnClientPreClose
        {
            get
            {
                return (string) this.ViewState["OnClientPreClose"];
            }
            set
            {
                this.ViewState["OnClientPreClose"] = value;
            }
        }

        [Description("Gets or sets script for Window Pre-Open event."), Category("Events")]
        public virtual string OnClientPreOpen
        {
            get
            {
                return (string) this.ViewState["OnClientPreOpen"];
            }
            set
            {
                this.ViewState["OnClientPreOpen"] = value;
            }
        }

        [Category("Events"), Description("Gets or sets script for Window Resize event.")]
        public virtual string OnClientResize
        {
            get
            {
                return (string) this.ViewState["OnClientResize"];
            }
            set
            {
                this.ViewState["OnClientResize"] = value;
            }
        }

        [Description("Gets or sets Opacity of Window."), Category("Displays")]
        public virtual int Opacity
        {
            get
            {
                return (int) this.ViewState["opacity"];
            }
            set
            {
                this.ViewState["opacity"] = value;
            }
        }

        [Category("Content Settings"), Description("Gets or sets overflow behaviours.")]
        public virtual OverflowStyles Overflow
        {
            get
            {
                return (OverflowStyles) this.ViewState["overflow"];
            }
            set
            {
                this.ViewState["overflow"] = value;
            }
        }

        [Category("Displays"), Description("Get or set the Opacity value of filter background")]
        public virtual int PageOpacity
        {
            get
            {
                return (int) this.ViewState["pageopacity"];
            }
            set
            {
                this.ViewState["pageopacity"] = value;
            }
        }

        [Description("Gets or sets ID of the element which Windows will have relative position to."), Category("Extras")]
        public virtual string RelativeElementID
        {
            get
            {
                return (string) this.ViewState["relativeelementid"];
            }
            set
            {
                this.ViewState["relativeelementid"] = value;
            }
        }

        [Category("Header Settings"), Description("Gets or sets whether the close button is showed.")]
        public virtual bool ShowCloseButton
        {
            get
            {
                return (bool) this.ViewState["closebutton"];
            }
            set
            {
                this.ViewState["closebutton"] = value;
            }
        }

        [Description("Gets or sets whether the Maximize button is showed."), Category("Header Settings")]
        public bool ShowMaximizeButton
        {
            get
            {
                return (bool) this.ViewState["maximizebutton"];
            }
            set
            {
                this.ViewState["maximizebutton"] = value;
            }
        }

        [Category("Header Settings"), Description("Gets or sets whether the Minimize button is showed.")]
        private bool ShowMinimizeButton
        {
            get
            {
                return (bool) this.ViewState["minimizebutton"];
            }
            set
            {
                this.ViewState["minimizebutton"] = value;
            }
        }

        [Description("Gets or sets whether statusbar is shown."), Category("Displays")]
        public virtual bool ShowStatusBar
        {
            get
            {
                return (bool) this.ViewState["showstatusbar"];
            }
            set
            {
                this.ViewState["showstatusbar"] = value;
            }
        }

        [Description("Gets or sets Status of Window.")]
        public virtual string Status
        {
            get
            {
                return (string) this.ViewState["status"];
            }
            set
            {
                this.ViewState["status"] = value;
            }
        }

        [Category("Initiation"), Description("Gets or sets Style.")]
        internal string Style
        {
            get
            {
                string styleFolder = this.StyleFolder;
                return styleFolder.Substring(styleFolder.LastIndexOf("/") + 1);
            }
        }

        [Category("Displays"), Description("Gets or sets Folder that contain style for window.")]
        public virtual string StyleFolder
        {
            get
            {
                return (string) this.ViewState["stylefolder"];
            }
            set
            {
                string relativeUrl = value.Replace(@"\", "/");
                relativeUrl = base.ResolveUrl(relativeUrl);
                this.ViewState["stylefolder"] = relativeUrl;
            }
        }

        [Description("Gets or sets root folder of styles."), Category("Initiation")]
        internal string StyleRootFolder
        {
            get
            {
                string styleFolder = this.StyleFolder;
                if (styleFolder.LastIndexOf("/") == -1)
                {
                    return "";
                }
                return styleFolder.Substring(0, styleFolder.LastIndexOf("/"));
            }
        }

        [Description("Gets or sets Title of Window."), Category("Header Settings")]
        public virtual string Title
        {
            get
            {
                return (string) this.ViewState["title"];
            }
            set
            {
                this.ViewState["title"] = value;
            }
        }

        [Description("Gets or sets Top position of Window"), Category("Position and Size")]
        public virtual int Top
        {
            get
            {
                return (int) this.ViewState["top"];
            }
            set
            {
                this.ViewState["top"] = value;
            }
        }

        [Description("Gets or sets Url to be loaded into Window."), Category("Content Settings")]
        public virtual string Url
        {
            get
            {
                return (string) this.ViewState["url"];
            }
            set
            {
                this.ViewState["url"] = value;
            }
        }

        [Description("Gets or sets whether Window is visible after page is loaded."), Category("Behaviours")]
        public virtual bool VisibleOnLoad
        {
            get
            {
                return (bool) this.ViewState["visibleonload"];
            }
            set
            {
                this.ViewState["visibleonload"] = value;
            }
        }

        [Category("Position and Size"), Description("Gets or sets width of Window")]
        public virtual int Width
        {
            get
            {
                return (int) this.ViewState["width"];
            }
            set
            {
                this.ViewState["width"] = (value > this.MinWidth) ? value : this.MinWidth;
            }
        }
    }
}

